import sqlite3
''' 连接数据库  创建test.db  如果不存在的话，会自动创建一个 '''
conn = sqlite3.connect("test.db")
''' 创建一个游标 '''
cur = conn.cursor()

''' 执行一条语句，创建user表 '''
#sql = "CREATE TABLE COMPANY (ID integer PRIMARY KEY autoincrement," \
#      "NAME VARCHAR (30)," \
#      "PASSWORD VARCHAR (30)" \
#      ")"
#cur.execute(sql)

sql = "insert into COMPANY (name, password) values ('love2dd', '520520')"  #添加一条记录
#sql2 = "UPDATE COMPANY SET name = ? ,PASSWORD = ? WHERE  ID = ? "     #修改记录
#values = ('lovett','5201314',1)
cur.execute(sql)
#a = cur.rowcount
#print(a)

#sql3 = "SELECT * FROM COMPANY"   #查询这个表
#B = cur.execute(sql3)
#sql4 = "select * from COMPANY where id = ?"  #查询这个表的字段
#values = (1,)
#A = cur.execute(sql4,values)
#values = cur.fetchall()  # 获取查询结果
#print(values)
conn.commit()
cur.close()
conn.close()
